const DB = require('../../config/DB')
const {
    Op
} = require('sequelize')

class UserController {
    // 查询用户
    async listUser(ctx) {
        const { count, rows } = await DB.user.findAndCountAll()
        const data = {
            rows,
            meta: {
                count
            }
        }
        global.Response.success(ctx, undefined, data)

    }
    // 新增用户
    async addUser(ctx) {
        let { username, password } = ctx.request.body
        const newUser = await DB.user.create({
            username,
            password
        })
        global.Response.success(ctx, '新增用户成功', newUser)
    }
    // 更新用户信息
    async editUserInfo(ctx) {
        global.Response.success(ctx, undefined, '更新用户信息')
    }
    // 删除用户
    async deleteUser(ctx) {
        global.Response.success(ctx, undefined, '删除用户')
    }

}

module.exports = new UserController